package com.victor9ac.mashup.api.travel;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.victor9ac.mashup.api.Transport;

public class Travel {

	public Travel() {
		
	}
	
	String from; 
	String to;
	
	String fromCalculated;
	List <Airline> airlines;
	List<Agency> agencies;	
	Airport airportFrom;
	Airport airportTo;
	

	List<TravelRoute> travelRoutes;


	public String getFrom() {
		return from;
	}


	public void setFrom(String from) {
		this.from = from;
	}


	public String getTo() {
		return to;
	}


	public void setTo(String to) {
		this.to = to;
	}

	public List<TravelRoute> getTravelRoutes() {
		if (travelRoutes == null){
			travelRoutes = new ArrayList<TravelRoute>();
		}
		return travelRoutes;
	}
	
	
	public boolean hasRoutes(Travel travel){
		return travel.getTravelRoutes() != null && !travel.getTravelRoutes().isEmpty();
	}
	

	public void generateTransports(){
		buildRouteTransport();
	}


	private void buildRouteTransport() {
		if (hasRoutes(this)){
			for (TravelRoute route: this.travelRoutes){
				route.buildTransport();
			}
		}
	}
	

	public void setTravelRoutes(List<TravelRoute> travelRoutes) {
		this.travelRoutes = travelRoutes;
	}
	


	public Airport getAirportFrom() {
		return airportFrom;
	}


	public void setAirportFrom(Airport airportFrom) {
		this.airportFrom = airportFrom;
	}


	public Airport getAirportTo() {
		return airportTo;
	}


	public void setAirportTo(Airport airportTo) {
		this.airportTo = airportTo;
	}


	public List<Agency> getAgencies() {
		if (agencies == null){
			agencies = new ArrayList<Agency>();
		}
		return agencies;
	}


	public void setAgencies(List<Agency> agencies) {
		this.agencies = agencies;
	}


	public List<Airline> getAirlines() {
		if (airlines == null){
			airlines = new ArrayList<Airline>();
		}
		return airlines;
	}


	public void setAirlines(List<Airline> airlines) {
		this.airlines = airlines;
	}


	public String getFromCalculated() {
		return fromCalculated;
	}


	public void setFromCalculated(String fromCalculated) {
		this.fromCalculated = fromCalculated;
	}

	
}
